<?php
include('../../__global.php');
include(SERVER_ROOT_PATH.'/include/config/ml_guang_config.php');
class aj_scrollnew extends ml_controller
{
    //private $page_type;
    private $block;
    private $color;
    private $minPrice;
    private $maxPrice;
    private $filter;
    private $order;

    public function initParam()
    {
        //$this->page_type = $this->input('order' , 'g' , '24_hot');
        $page = (int)$this->input('page' , 'G' , 1);
        $block = (int)$this->input('segment' , 'G' , 2);
        $block = $block<1 ? 1 : $block;
        $block = $block>ML_GUANG_BLOCK ? ML_GUANG_BLOCK : $block;
        $page = $page < 1 ? 1 : $page;
        $page = $page > ML_GUANG_TOTAL_PAGE ? 1 : $page;
        $this->block = ($page-1)*ML_GUANG_BLOCK + $block-1;
        $this->color = $this->input('color');
        $this->order = $this->input('order','G','hot');
        $this->maxPrice = $this->input('maxPrice');
        $this->minPrice = $this->input('minPrice');
        $this->filter = $this->input('filter');
        define('ML_SHOW_GOODS_FRM', 'pb'.$this->block);
    }
    public function checkParam()
    {
        $this->check_referer();
//        if(!in_array($this->page_type , array('24_new' , '24_hot' ,'7_new' ,'7_hot')))
//        $this->api_output(ML_RCODE_BUSY);
            
    }
    public function main()
    {
        //行为LOG start
        $aTarget = array(
            'order' => $this->order,
            'block' => $this->block,
        );
        if(!empty($this->color))
            $aTarget['color'] = $this->color;
        if((!empty($this->minPrice)) || (!empty($this->maxPrice))){
            $aTarget['price'] = trim($this->minPrice.'_'.$this->maxPrice, '_');
        }
        ml_tool_actionlog::view_guang($this->__visitor['uid'] , $aTarget);
        //行为LOG end
        $option = array('sort'=>$this->order,'tag'=>array($this->filter),'color'=>$this->color,'maxPrice'=>$this->maxPrice,'minPrice'=>$this->minPrice,'block'=>$this->block);        
        $oGuang = new ml_biz_guang();
        $oGuang->check($option);
        $content = $oGuang->main();
        $oPin = new ml_biz_pin_content();
        $tmp = $oPin->output($this->__visitor['uid'], $content['rows'], false,true);

        
        $data['items'] = array_values($tmp);
        $data['lastSegment'] = $this->block == ceil($content['total']/ML_GUANG_PAGESIZE)-1 ? true : false;


        $this->api_output(ML_RCODE_SUCC , $data);
    }

}
new aj_scrollnew();